/**
 * 通用类型定义
 */

// 基础选项类型
export interface Option {
  label: string
  value: string | number
  disabled?: boolean
  children?: Option[]
}

// 表格列类型
export interface TableColumn {
  prop: string
  label: string
  width?: number
  minWidth?: number
  sortable?: boolean
  resizable?: boolean
  align?: 'left' | 'center' | 'right'
  headerAlign?: 'left' | 'center' | 'right'
  showOverflowTooltip?: boolean
  fixed?: boolean | 'left' | 'right'
  formatter?: (row: any, column: any, cellValue: any) => string
  render?: (row: any, column: any, cellValue: any) => any
}

// 表单项类型
export interface FormItem {
  prop: string
  label: string
  type: 'input' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'date' | 'upload' | 'custom'
  required?: boolean
  placeholder?: string
  options?: Option[]
  rules?: any[]
  span?: number
  disabled?: boolean
  readonly?: boolean
  clearable?: boolean
  multiple?: boolean
  props?: Record<string, any>
  component?: any
  slot?: string
}

// 搜索条件类型
export interface SearchCondition {
  field: string
  label: string
  type: 'input' | 'select' | 'date' | 'daterange'
  options?: Option[]
  placeholder?: string
  clearable?: boolean
  multiple?: boolean
  span?: number
}

// 按钮配置类型
export interface ButtonConfig {
  text: string
  type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text'
  size?: 'large' | 'default' | 'small'
  icon?: string
  disabled?: boolean
  loading?: boolean
  plain?: boolean
  round?: boolean
  circle?: boolean
  permission?: string
  onClick?: () => void
}

// 树形数据类型
export interface TreeNode {
  id: number | string
  label: string
  value?: any
  children?: TreeNode[]
  disabled?: boolean
  isLeaf?: boolean
  parent?: TreeNode
  level?: number
  expanded?: boolean
  selected?: boolean
  checked?: boolean
  indeterminate?: boolean
  loading?: boolean
  icon?: string
  [key: string]: any
}

// 面包屑导航类型
export interface BreadcrumbItem {
  label: string
  path?: string
  icon?: string
  disabled?: boolean
}

// 标签页类型
export interface TabItem {
  name: string
  label: string
  icon?: string
  disabled?: boolean
  closable?: boolean
  component?: any
  props?: Record<string, any>
}

// 菜单项类型
export interface MenuItemConfig {
  id: string
  label: string
  icon?: string
  path?: string
  disabled?: boolean
  divided?: boolean
  command?: string
  children?: MenuItemConfig[]
}

// 卡片配置类型
export interface CardConfig {
  title: string
  subtitle?: string
  extra?: string
  bodyStyle?: Record<string, any>
  shadow?: 'always' | 'hover' | 'never'
  size?: 'large' | 'default' | 'small'
}

// 步骤条类型
export interface StepItem {
  title: string
  description?: string
  icon?: string
  status?: 'wait' | 'process' | 'finish' | 'error' | 'success'
  disabled?: boolean
}

// 时间轴类型
export interface TimelineItem {
  timestamp: string
  title: string
  content?: string
  type?: 'primary' | 'success' | 'warning' | 'danger' | 'info'
  color?: string
  size?: 'normal' | 'large'
  icon?: string
  hollow?: boolean
  placement?: 'top' | 'bottom'
}

// 图表配置类型
export interface ChartConfig {
  type: 'line' | 'bar' | 'pie' | 'scatter' | 'radar' | 'gauge'
  title?: string
  subtitle?: string
  xAxis?: any
  yAxis?: any
  series?: any[]
  legend?: any
  tooltip?: any
  color?: string[]
  grid?: any
  dataZoom?: any
  toolbox?: any
  animation?: boolean
  theme?: string
}

// 文件信息类型
export interface FileInfo {
  name: string
  size: number
  type: string
  url?: string
  status: 'ready' | 'uploading' | 'success' | 'error'
  progress?: number
  error?: string
  response?: any
  raw?: File
  uid?: string
}

// 地址信息类型
export interface AddressInfo {
  country?: string
  province: string
  city: string
  district?: string
  address: string
  zipCode?: string
  lat?: number
  lng?: number
}

// 设备信息类型
export interface DeviceInfo {
  type: 'desktop' | 'mobile' | 'tablet'
  os: string
  browser: string
  version: string
  userAgent: string
  screen: {
    width: number
    height: number
  }
  viewport: {
    width: number
    height: number
  }
}

// 主题配置类型
export interface ThemeConfig {
  mode: 'light' | 'dark'
  primaryColor: string
  secondaryColor: string
  backgroundColor: string
  textColor: string
  borderColor: string
  fontSize: number
  borderRadius: number
  customCSS?: string
}

// 语言配置类型
export interface LanguageConfig {
  code: string
  name: string
  flag: string
  messages: Record<string, string>
}

// 键值对类型
export interface KeyValuePair<T = any> {
  key: string
  value: T
  label?: string
  type?: string
  description?: string
}

// 状态类型
export type Status = 'success' | 'error' | 'warning' | 'info'

// 尺寸类型
export type Size = 'large' | 'default' | 'small'

// 位置类型
export type Placement = 'top' | 'bottom' | 'left' | 'right'

// 触发方式类型
export type Trigger = 'click' | 'hover' | 'focus' | 'manual'

// 加载状态类型
export type LoadingState = 'idle' | 'loading' | 'success' | 'error'

// 排序方向类型
export type SortDirection = 'asc' | 'desc'

// HTTP方法类型
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'

// 环境类型
export type Environment = 'development' | 'production' | 'test' 